/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sellcar;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Fabio Valenzuela
 */
public class Cadastro_UsuarioDAO {
    
    private Connection connection;
    
    public Cadastro_UsuarioDAO(){
        this.connection = new ConnectionFactory().getConnection();
    }
    
    public void adiciona(Usuario usuario){
        
        String sql = "insert into tb_usuario" + "(DESC_LOGIN,SENHA)" + "values(?,?)";
        
        try{
            PreparedStatement stmt = connection.prepareStatement(sql);
            stmt.setString(1, usuario.getUsuario());
            stmt.setString(2, usuario.getSenha());
            
        
            stmt.execute();
            stmt.close();
            connection.close();        
        }catch(SQLException e ){
            throw new RuntimeException(e);
        }
    }
        
}